#include"LinkList.h"
void SListTest1()
{
	SLK* phead = NULL;

	SListPushFront(&phead, 10);
	SListPushFront(&phead, 1233);

	SListPrint(phead);
}


void SListTest2()
{
	SLK* Plist = NULL;
	SListPushBack(&Plist, 12);
	SListPushBack(&Plist, 13);
	SListPushBack(&Plist, 14);
	SListPrint(Plist);

	
	SListPopBack(&Plist);
	SListPopBack(&Plist);
	SListPopBack(&Plist);
	SListPrint(Plist);
}
void SListTest3()
{
	SLK* Plist = NULL;
	SListPushBack(&Plist, 12);
	SListPushBack(&Plist, 13);
	SListPushBack(&Plist, 14);
	SListPrint(Plist);

	SListPopFront(&Plist);
	SListPopFront(&Plist);
	SListPopFront(&Plist);
	SListPopFront(&Plist);
	
	SListPrint(Plist);


}
void SListTest4()
{
	SLK* Plist = NULL;
	SListPushBack(&Plist, 12);
	SListPushBack(&Plist, 13);
	SListPushBack(&Plist, 14);
	SListPrint(Plist);
	SLK* f = SListFind(Plist, 13);
	SListInset(&Plist, f, 122);
	SListErase(&Plist, f);
    SListPrint(Plist);
}
void SListTest5()
{
	SLK* Plist = NULL;
	SListPushBack(&Plist, 12);
	SListPushBack(&Plist, 13);
	SListPushBack(&Plist, 14);
	SListPrint(Plist);
	SLK* f = SListFind(Plist, 13);

	SListInsetAfter(Plist, f, 122);
	SListInsetAfter(Plist, f, 123);
	SListEraseAfter(f);
	SListEraseAfter(f);
	SListPrint(Plist);
	SListDestory(&Plist);
}

void menu()
{
	printf("-------------------------------------------\n");
	printf("-------------     简易版本     ------------\n");
	printf("1、增    2、删   3、改   4、查    5、打印\n");
	printf("-------------------------------------------\n");

}
void TestMenu()
{
	SLK* head = NULL;
	int input = 0;
	SListDataType x = 0;
	SLK* f = NULL;
	do
	{
		menu();
		printf("input：");
		scanf("%d", &input);
		switch (input)
		{
		case 1:
			printf("请输入要增加的数据: ");
			scanf("%d", &x);
			SListPushBack(&head, x);
			break;
		case 2:
			SListPopBack(&head);
			break;
		case 3:
			printf("请输入要修改的值：");
			scanf("%d", &x);
			f = SListFind(head, x);
			if (f != NULL)
			{
				printf("更改为：");
				scanf("%d", &x);
				SListChange(f, x);
				printf("更该成功\n");
			}
			else
				printf("没有该值，更改失败\n");
			break;
		case 4:
			printf("请输入要查的值：");
			scanf("%d", &x);
			 f = SListFind(head, x);
			if (f == NULL)
				printf("没有该值\n");
			else
				printf("找到了,%p\n", f);
			break;
		case 5:
			printf("打印结果:\n");
			SListPrint(head);
			break;
		case 0:
			printf("退出程序\n");
			SListDestory(&head);
			break;
		default:
			printf("没有该选项，请重新输入\n");
			break;
		}
	} while (input);
}
int main()
{
	// SListTest1();
	// SListTest2();
	// SListTest3();
	//  SListTest4();
	// SListTest5();
	TestMenu();
	return 0;
}